<?php
/********************************************************************
 *	Author:
 *		Jestery Liu <jestery@gmail.com>
 *		http://www.pte.cn
 *
 *	File:			ErrorHandler.class.php
 *	Create Date:	2007-05-14 17:35:52 CST
 *******************************************************************/
require_once(PTE::getCoreLibsPath().'ErrorHandler.interface.php');

class ErrorHandler implements IErrorHandler
{
	private $errorLogFile;
	
	public function Handle($errno, $msg, $filename, $line, $vars)
	{
		$now = date("Y-m-d H:i:s");
		$err = "$now\nError($errno):\n";
		$err.= "In $filename on line $line.\n";
		$err.= "Message:\n$msg\n----------------------------------------\n";
		if (PTE::getDebug() || $_GET['debug']==PTE::getDebugString())
		{
			echo nl2br($err);
		}
		error_log($err, 3, $this->errorLogFile);
		exit();
	}
	
	public function getErrorLogFile()
	{
		return $this->errorLogFile;
	}
	public function setErrorLogFile($file)
	{
		$this->errorLogFile = $file;
	}
}
